package BitCreekTracker;

import BitCreekLib.Host;

import static java.lang.System.currentTimeMillis;

/**
 * Created by Ivan Litsvinenka e Emanuele Ricci
 * Date: 29-lug-2009
 * Time: 16.01.06
 */
public class TrackerPeer {

    private Host host;
    private long lastKA;

    public TrackerPeer( Host host ) {
        this.host = host;
        this.lastKA = currentTimeMillis();
    }

    public Host getHost() {
        return host;
    }

    public  long getLastKA() {
        return lastKA;
    }

    public  void setLastKA() {
        this.lastKA = currentTimeMillis();
    }

    public String toString() {
        return this.host.getAddress().toString();
    }

    @Override public boolean equals(Object compare) {
        //check for self-comparison
        if ( this == compare ) return true;
        if ( !(compare instanceof TrackerPeer) ) return false;

        TrackerPeer compareObj = (TrackerPeer)compare;

        return ( this.host.equals(compareObj.getHost()) );


    }

}
